#define _CRT_SECURE_NO_WARNINGS  1
#include<stdio.h>
#include<stdlib.h> 
typedef struct stu
{
	int data;
	struct stu* next;
}stu;
int main()
{
	int n, px;
	scanf("%d%d", &n, &px);
	stu* p=NULL, * head=NULL, * tail=NULL;
	for (int i = 0; i < n; i++)
	{
		p = (stu*)malloc(sizeof(stu));
		p->data = i + 1;
		if (i == 0)
		{
			head = p;
		}
		else
		{
			tail->next = p;
		}
		tail = p;
	}
	p->next = head;

	stu* s1 = tail, *s2 = tail->next;
	int count = 0;
	int i = 1;
	while (count!=n-1)
	{
		if (i == px)
		{
			printf("%d ", s2->data);
			s1->next = s2->next;
			free(s2);
			s2 = s1->next;
			count++;
			i = 1;
		}
		s1 = s1->next;
		s2 = s2->next;
		i++;
	}
	printf("%d", s2->data);
	return 0;
}